﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Object_Manager : MonoBehaviour
{
    public static Object_Manager _instance;
    public Transform Object_prefab;
    private static float randon_scale = 0.5f;

    private void Awake()
    {
        _instance = this;
    }

    public void Emerge_Obj(int id, Vector3 position)
    {
        Vector3 random = Random.insideUnitSphere;
        random.Set(random.x, Mathf.Abs(random.y), random.z);

        Transform prefab = Instantiate(Object_prefab, position + random, new Quaternion());
        Sprite_Prop _Prop = prefab.GetComponent<Sprite_Prop>();

        _Prop.Set_Obj_Info(id);
    }

    public void Emerge_Obj(Objectinfo objectinfo, Vector3 position)
    {
        Vector3 random = Random.insideUnitSphere;
        random.Set(random.x, Mathf.Abs(random.y), random.z);

        Transform prefab = Instantiate(Object_prefab, position + random, new Quaternion());
        Sprite_Prop _Prop = prefab.GetComponent<Sprite_Prop>();

        _Prop.Set_Obj_Info(objectinfo);
    }

    public void Emerge_Objs(List<int> ids, Vector3 position)
    {
        foreach(int id in ids)
        {
            Emerge_Obj(id, position);
        }
    }

    public void Emerge_Objs(List<Objectinfo> objectinfos, Vector3 position)
    {
        foreach(Objectinfo one_info in objectinfos)
        {
            Emerge_Obj(one_info, position);
        }
    }
}
